//
//  NSStringAdditions.h
//  Test
//
//  Created by tan on 13-5-20.
//  Copyright (c) 2013年 tan. All rights reserved.
//

#import <Foundation/Foundation.h>
#import <CommonCrypto/CommonDigest.h>
#import <CoreText/CoreText.h>

@interface NSString (NSStringAdditions)

+ (NSString *)UUID;

- (NSArray *)traverseUsingRegularExp:(NSString *)reg;
- (BOOL)matchRegularExp:(NSString *)reg;

- (NSString *)trim;

- (NSString *)stringFromMD5;
- (NSString *)stringFromSHA1;

- (NSString *)encodeForURL;
- (NSString *)encodeForURLReplacingSpacesWithPlus;
- (NSString *)decodeFromURL;

+ (NSString *)jsonRepresentWithObject:(id)object options:(NSJSONWritingOptions)options;
- (id)jsonResolveWithOptions:(NSJSONReadingOptions)options;

- (BOOL)isPureInt;
- (BOOL)isPureFloat;

- (CGFloat)heightWithFont:(UIFont *)font size:(CGSize)size;
- (CGFloat)heightWithFont:(UIFont *)font
              lineSpacing:(CGFloat)lineSpacin   // -1 default
                  kerning:(CGFloat)kerning      // -1 default
                     width:(CGFloat)width;

- (NSAttributedString *)attributedStringWithFont:(UIFont *)font
                                     lineSpacing:(CGFloat)lineSpacing   // -1 default
                                         kerning:(CGFloat)kerning;      // -1 default

@end
